<!--
//******************************************************************
//* Copyright (c) 2004 Ford Motor Company. All Rights Reserved.
//*
//*
//* $$Workfile:   costStructureItem.jsp  $$
//* $$Revision:   1.1  $$
//* $$Author:   TMALDON4  $$
//* $$Date:   Feb 12 2009 14:04:54  $$
//*
//* Description: Description of file goes here
//******************************************************************
-->
<%@ taglib uri="http://jakarta.apache.org/struts/tags-bean" prefix="bean" %>
<%@ taglib uri="http://jakarta.apache.org/struts/tags-html" prefix="html" %>
<%@ taglib uri="http://jakarta.apache.org/struts/tags-logic" prefix="logic" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%@ taglib uri="http://displaytag.sf.net/el" prefix="display-el" %>
<%@ taglib uri="ford-arg/tags" prefix="ft" %>

<script language="javascript">

	function findCostStructureItem() {
		document.CostStructureItemForm.action = "CostStructureItemActionFind.do";
		document.CostStructureItemForm.section.value = "find";
		document.CostStructureItemForm.submit();
	}

	function createEconomic() {
		document.CostStructureItemForm.action = "EconomicIndexDefActionInit.do";
		document.CostStructureItemForm.section.value = "newEconomic";		
		document.CostStructureItemForm.submit();
	}

	function createItemCategory() {
		document.CostStructureItemForm.action = "CostStructureItemCategoryActionInit.do";
		document.CostStructureItemForm.section.value = "newItemCategory";		
		document.CostStructureItemForm.submit();
	}
	
	function createUpdateCostStructureItem() {
		document.CostStructureItemForm.action = "CostStructureItemActionCreateUpdate.do";
		document.CostStructureItemForm.section.value = "createUpdate";		
		document.CostStructureItemForm.submit();
	}
	
	function proposeCostStructureItem() {
		document.CostStructureItemForm.action = "CostStructureItemActionPropose.do";
		document.CostStructureItemForm.section.value = "propose";		
		document.CostStructureItemForm.submit();	
	}
	
	function approveCostStructureItem() {
		document.CostStructureItemForm.action = "CostStructureItemActionApprove.do";
		document.CostStructureItemForm.section.value = "approve";
		document.CostStructureItemForm.submit();	
	}	
	
	function approveCostStructureFromList() {
		document.CostStructureItemForm.action = "CostStructureItemActionApprove.do";
		document.CostStructureItemForm.section.value = "approve";
	}
	
	function proposeCostStructureFromList() {
		document.CostStructureItemForm.action = "CostStructureItemActionPropose.do";
		document.CostStructureItemForm.section.value = "propose";
	}	
	
	function clearCostStructureItem() {
		<%-- TODO Cambiar CostStructureItemActionNew por CostStructureItemActionClear --%>
		document.CostStructureItemForm.action = "CostStructureItemActionNew.do";
		document.CostStructureItemForm.section.value = "newItem";
		document.CostStructureItemForm.submit();
	}
	
	function deleteCostStructureItem() {
		if (confirm('<bean:message key="costStructure.item.confirmDelete" />')) {
			document.CostStructureItemForm.action = "CostStructureItemActionDelete.do";
			document.CostStructureItemForm.section.value = "delete";		
			document.CostStructureItemForm.submit();
		}
	}
	
	function discardCostStructureItem() {
		document.CostStructureItemForm.action = "CostStructureItemActionFind.do";
		document.CostStructureItemForm.section.value = "discard";
		document.CostStructureItemForm.submit();		
	}
	
	function editCostStructureFromList() {
		document.CostStructureItemForm.action = "CostStructureItemActionEdit.do";
		document.CostStructureItemForm.section.value = "editFromList";	
	}
	
	function deleteCostStructureFromList() {
		if (confirm('<bean:message key="costStructure.item.confirmDelete" />')) {
			document.CostStructureItemForm.action = "CostStructureItemActionDelete.do";
			document.CostStructureItemForm.section.value = "deleteFromList";
		}
	}	
	
	function cleanFindFields() {
		document.CostStructureItemForm.action = "CostStructureItemActionCleanFind.do";
		document.CostStructureItemForm.section.value = "cleanFind";
		document.CostStructureItemForm.submit();
	}
		
</script>

<table>
	<tr>
		<td colspan="2"><h2><bean:message key="costStructure.item.list.label.title"/></h2></td>
	</tr>
</table>
<br />
<html:form action="/CostStructureItemActionFind">
<html:hidden property="section" />
	<table>
		<tr>
			<td>
				<table>
					<tr>
						<td class="text_blue_bold align_left" colspan="100%">
							<bean:message key="costStructure.item.label.filter" />
						</td>
					</tr>
					<tr>
						<td class="text_blue_bold align_left">
							<bean:message key="costStructure.itemCategory"/>
						</td>
						<td class="align_left">
							<html:select property="itemCatCodeSelFind">
								<html:option value="-1" key="label.allOption"/>
								<html:options collection="itemCategories" property="eesc05ItemcatgryNumberK" labelProperty="eesc05ItemcatgryNameN" />
							</html:select>
							&nbsp;
							<logic:equal property="screen" value="list" name="CostStructureItemForm">
								<html:button property="newItemCategory" styleClass="button" onclick="createItemCategory();"><bean:message key="costStructure.item.button.newItemCategory" /></html:button>
								&nbsp;
								<html:button property="newItem" onclick="clearCostStructureItem();" styleClass="button"><bean:message key="costStructure.item.button.newItem" /></html:button>
							</logic:equal>
						</td>
					</tr>
					<tr>
						<td class="text_blue_bold align_left">
							<bean:message key="costStructure.item.label.code" />
						</td>
						<td class="align_left">
							<html:text property="codeFind" />
						</td>					
					</tr>
					<tr>
						<td class="text_blue_bold align_left">
							<bean:message key="costStructure.item.label.name" />
						</td>
						<td class="align_left">
							<html:text property="nameFind" maxlength="50" />&nbsp;
							<html:button property="find" onclick="cleanFindFields();" styleClass="button"><bean:message key="label.clean" /></html:button>
							<html:button property="find" onclick="findCostStructureItem();" styleClass="button"><bean:message key="label.find" /></html:button>
						</td>
					</tr>
				</table>
			</td>
		</tr>
		<tr>
			<td height="15px">
			</td>
		</tr>
	
	<%-- ################################################################################### --%>
	<%-- ######################    DETAIL SCREEN       ##################################### --%>
	<%-- ################################################################################### --%>
	<logic:equal property="screen" value="detail" name="CostStructureItemForm">
		<tr>
			<td>
				<table class="table1" style="width: 600px;">
					<tr>
						<td class="text_blue_bold align_left">
							<bean:message key="costStructure.item.label.code" />
						</td>
						<td colspan="2" class="align_left">
							<bean:write name="CostStructureItemForm" property="codeCreateUpdate" />
						</td>
					</tr>
					<tr>
						<td class="text_blue_bold align_left">
							<bean:message key="costStructure.item.label.name" />
						</td>
						<td colspan="2" class="align_left">
							<html:text property="nameCreateUpdate" maxlength="50" />
						</td>
					</tr>
					<tr>
						<td height="15px" colspan="100%">
						</td>
					</tr>
					<tr>
						<td class="text_blue_bold align_left">
							<bean:message key="costStructure.itemCategory" />
						</td>
						<td class="align_left">
							<html:select property="itemCatCodeSel">
								<html:option value="-2" key="label.selectOption"/>
								<html:options collection="itemCategories" property="eesc05ItemcatgryNumberK" labelProperty="eesc05ItemcatgryNameN" />
							</html:select>
						</td>
						<td class="align_left">
							<html:button property="newItemCategory" onclick="createItemCategory();" styleClass="button"><bean:message key="costStructure.item.button.newItemCategory" /></html:button>
						</td>
					</tr>
					<tr>
						<td class="text_blue_bold align_left">
							<bean:message key="costStructure.item.label.defaultEconomic" />
						</td>
						<td class="align_left">
							<html:select property="economicCodeSel">
								<html:option value="-2" key="label.selectOption" />
								<html:option value="-1" key="costStructure.item.label.noIndexable" />
								<html:options collection="economics" property="eese01EconNumberK" labelProperty="eese01EconNameN" />
							</html:select>						
						</td>
						<td class="align_left">
							<html:button property="newEconomic" onclick="createEconomic();" styleClass="button"><bean:message key="costStructure.item.button.newEconomic" /></html:button>
						</td>
					</tr>
					<tr>
						<td style="height: 100px">
						</td>						
					</tr>
					<tr>
						<td colspan="100%">
							<hr />
							<table class="table1" style="width: 590px;">
								<tr>
									<td class="align_left">									
										<logic:empty property="createdBy" name="CostStructureItemForm">
											<html:button property="save" onclick="createUpdateCostStructureItem();" styleClass="button_small"><bean:message key="label.save" /></html:button>
										</logic:empty>
										<logic:notEmpty property="createdBy" name="CostStructureItemForm">
											<bean:define id="createdBy" name="CostStructureItemForm" property="createdBy" />
											<bean:define id="createdDate" name="CostStructureItemForm" property="createdDate" />
											<bean:message key="text.createdBy" arg0="${createdBy}" arg1="${createdDate}" />
										</logic:notEmpty>
									</td>
								</tr>
								<tr>
									<td class="align_left">
										<logic:notEmpty property="createdBy" name="CostStructureItemForm">
											<logic:empty property="proposedBy" name="CostStructureItemForm">
												<html:button property="propose" onclick="proposeCostStructureItem();" styleClass="button_small"><bean:message key="label.propose" /></html:button>
											</logic:empty>
										</logic:notEmpty>
										<logic:notEmpty property="proposedBy" name="CostStructureItemForm">
											<bean:define id="proposedBy" name="CostStructureItemForm" property="proposedBy" />
											<bean:define id="proposedDate" name="CostStructureItemForm" property="proposedDate" />
											<bean:message key="text.proposedBy" arg0="${proposedBy}" arg1="${proposedDate}" />
										</logic:notEmpty>
									</td>								
								</tr>
								<tr>
									<td class="align_left">
										<logic:notEmpty property="proposedBy" name="CostStructureItemForm">
											<logic:empty property="approvedBy" name="CostStructureItemForm">
												<html:button property="approve" onclick="approveCostStructureItem();" styleClass="button_small"><bean:message key="label.approve" /></html:button>											
											</logic:empty>											
										</logic:notEmpty>
										<logic:notEmpty property="approvedBy" name="CostStructureItemForm">
											<bean:define id="approvedBy" name="CostStructureItemForm" property="approvedBy" />
											<bean:define id="approvedDate" name="CostStructureItemForm" property="approvedDate" />
											<bean:message key="text.approvedBy" arg0="${approvedBy}" arg1="${approvedDate}" />
										</logic:notEmpty>
									</td>
								</tr>
								<tr>
									<td class="align_left">
										<logic:notEmpty property="lastModifiedBy" name="CostStructureItemForm">
											<bean:define id="lastModifiedBy" name="CostStructureItemForm" property="lastModifiedBy" />
											<bean:define id="lastModifiedDate" name="CostStructureItemForm" property="lastModifiedDate" />										
											<bean:message key="text.lastModifiedBy" arg0="${lastModifiedBy}" arg1="${lastModifiedDate}" />											
										</logic:notEmpty>
									</td>
								</tr>
							</table>
						</td>
					</tr>					
				</table>
			</td>
			<td class="align_left" valign="top">
				<html:button property="newItem" onclick="clearCostStructureItem()" styleClass="button"><bean:message key="costStructure.item.button.newItem" /></html:button>
				<br />
				<html:button property="deleteItem" onclick="deleteCostStructureItem()" styleClass="button"><bean:message key="costStructure.item.button.deleteItem" /></html:button>
				<br />
				<br />				
				<html:button property="saveChanges" onclick="createUpdateCostStructureItem()" styleClass="button"><bean:message key="costStructure.item.button.saveChanges" /></html:button>
				<br />				
				<html:button property="discardChanges" onclick="discardCostStructureItem()" styleClass="button"><bean:message key="costStructure.item.button.discardChanges" /></html:button>												
			</td>
		</tr>
	</logic:equal>
	
	<%-- ################################################################################### --%>
	<%-- ######################    LIST SCREEN       ##################################### --%>
	<%-- ################################################################################### --%>	
	<logic:equal property="screen" value="list" name="CostStructureItemForm">
		<bean:define id="codeTitle">
			<bean:message key="costStructure.label.tableHeader.code" />
		</bean:define>
		<bean:define id="descriptionTitle">
			<bean:message key="costStructure.label.tableHeader.name" />
		</bean:define>
		<bean:define id="categoryTitle">
			<bean:message key="costStructure.label.tableHeader.category" />
		</bean:define>
		<bean:define id="defaultEconomicTitle">
			<bean:message key="costStructure.label.tableHeader.defaultEconomic" />
		</bean:define>
		<bean:define id="creationTitle">
			<bean:message key="costStructure.label.tableHeader.creation" />
		</bean:define>
		<bean:define id="proposalTitle">
			<bean:message key="costStructure.label.tableHeader.proposal" />
		</bean:define>
		<bean:define id="approvalTitle">
			<bean:message key="costStructure.label.tableHeader.approval" />
		</bean:define>
		<bean:define id="actionsTitle">
			<bean:message key="costStructure.label.tableHeader.actions" />
		</bean:define>
						
		<tr>
			<td>
				<%-- Mantiene el numero de pagina despues del submit --%>
				<ft:saveActivePageNumber/>
				<display-el:table 	class="table1" style="width: 800px;" cellpadding="5" uid="item"									
									name="sessionScope.CostStructureItemForm.items" pagesize="15"
									excludedParams="*" requestURI="CostStructureItemActionPaginate.do" >
					<display-el:column title="${codeTitle}" property="eesc06ItemNumberK" style="width: 5%;" class="cell1 text_bold border1_right border1_top align_left" headerClass="header border_right"/>
					<display-el:column title="${descriptionTitle}" property="eesc06ItemNameN" style="width: 20%;" class="cell1 text_bold border1_right border1_top align_left" headerClass="header border_right"/>
					<display-el:column title="${categoryTitle}" property="teesc05Itemcatgry.eesc05ItemcatgryNameN" style="width: 10%;" class="cell1 text_bold border1_right border1_top align_left" headerClass="header border_right"/>
					<display-el:column title="${defaultEconomicTitle}" property="teese01Economic.eese01EconNameN" style="width: 15%;" class="cell1 text_bold border1_right border1_top align_left" headerClass="header border_right"/>
					<display-el:column title="${creationTitle}" style="width: 10%;" decorator="ar.com.ford.it.fullEconomics.view.displaytag.CostStructureItemColumnDecorator" class="cell1 text_bold border1_right border1_top align_left" headerClass="header border_right">${item.eesc06CreateUserC}<br />${item.eesc06CreateS}</display-el:column>
					<display-el:column title="${proposalTitle}" style="width: 10%;" decorator="ar.com.ford.it.fullEconomics.view.displaytag.CostStructureItemColumnDecorator" class="cell1 text_bold border1_right border1_top align_left" headerClass="header border_right">
						<logic:empty name="item" property="eesc06ItemProposalUserC">
							<html:submit property="itemMapped(${item_rowNum})" styleClass="button" onclick="proposeCostStructureFromList();"><bean:message key="label.propose" /></html:submit>
						</logic:empty>
						<logic:notEmpty name="item" property="eesc06ItemProposalUserC">
							${item.eesc06ItemProposalUserC}<br />${item.eesc06ItemProposalS}
						</logic:notEmpty>
					</display-el:column>
					<display-el:column title="${approvalTitle}" style="width: 10%;" decorator="ar.com.ford.it.fullEconomics.view.displaytag.CostStructureItemColumnDecorator" class="cell1 text_bold border1_right border1_top align_left" headerClass="header border_right">
						<logic:notEmpty name="item" property="eesc06ItemProposalUserC">					
							<logic:empty name="item" property="eesc06ItemApprovalUserC">
								<html:submit property="itemMapped(${item_rowNum})" styleClass="button" onclick="approveCostStructureFromList();"><bean:message key="label.approve" /></html:submit>
							</logic:empty>
						</logic:notEmpty>
						<logic:notEmpty name="item" property="eesc06ItemApprovalUserC">
							${item.eesc06ItemApprovalUserC}<br />${item.eesc06ItemApprovalS}
						</logic:notEmpty>
					</display-el:column>					
					<display-el:column title="${actionsTitle}" style="width: 20%;" class="cell1 text_bold border1_right border1_top align_left" headerClass="header border_right">
						<html:submit property="itemMapped(${item_rowNum})" styleClass="button" onclick="editCostStructureFromList();"><bean:message key="label.edit" /></html:submit>&nbsp;
						<html:submit property="itemMapped(${item_rowNum})" styleClass="button" onclick="deleteCostStructureFromList();"><bean:message key="label.delete" /></html:submit>						
					</display-el:column>
				</display-el:table>			
			</td>					
		</tr>
	</logic:equal>
	
	</table>
</html:form>
